using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex{
    /// <summary>
    /// Strongly-typed collection for the VProductNews class.
    /// </summary>
    [Serializable]
    public partial class VProductNewsCollection : ReadOnlyList<VProductNews, VProductNewsCollection>
    {        
        public VProductNewsCollection() {}

    }

    /// <summary>
    /// This is  Read-only wrapper class for the vProductNews view.
    /// </summary>
    [Serializable]
    public partial class VProductNews : ReadOnlyRecord<VProductNews> 
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }

	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }

                return BaseSchema;
            }

        }

    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vProductNews", TableType.View, DataService.GetInstance("Adex"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = "dbo";
                //columns
                
                TableSchema.TableColumn colvarBrandID = new TableSchema.TableColumn(schema);
                colvarBrandID.ColumnName = "BrandID";
                colvarBrandID.DataType = DbType.Int32;
                colvarBrandID.MaxLength = 0;
                colvarBrandID.AutoIncrement = false;
                colvarBrandID.IsNullable = true;
                colvarBrandID.IsPrimaryKey = false;
                colvarBrandID.IsForeignKey = false;
                colvarBrandID.IsReadOnly = false;
                
                schema.Columns.Add(colvarBrandID);
                
                TableSchema.TableColumn colvarBrandCode = new TableSchema.TableColumn(schema);
                colvarBrandCode.ColumnName = "BrandCode";
                colvarBrandCode.DataType = DbType.Int32;
                colvarBrandCode.MaxLength = 0;
                colvarBrandCode.AutoIncrement = false;
                colvarBrandCode.IsNullable = true;
                colvarBrandCode.IsPrimaryKey = false;
                colvarBrandCode.IsForeignKey = false;
                colvarBrandCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarBrandCode);
                
                TableSchema.TableColumn colvarBrandName = new TableSchema.TableColumn(schema);
                colvarBrandName.ColumnName = "BrandName";
                colvarBrandName.DataType = DbType.String;
                colvarBrandName.MaxLength = 255;
                colvarBrandName.AutoIncrement = false;
                colvarBrandName.IsNullable = true;
                colvarBrandName.IsPrimaryKey = false;
                colvarBrandName.IsForeignKey = false;
                colvarBrandName.IsReadOnly = false;
                
                schema.Columns.Add(colvarBrandName);
                
                TableSchema.TableColumn colvarProductID = new TableSchema.TableColumn(schema);
                colvarProductID.ColumnName = "ProductID";
                colvarProductID.DataType = DbType.Int32;
                colvarProductID.MaxLength = 0;
                colvarProductID.AutoIncrement = false;
                colvarProductID.IsNullable = false;
                colvarProductID.IsPrimaryKey = false;
                colvarProductID.IsForeignKey = false;
                colvarProductID.IsReadOnly = false;
                
                schema.Columns.Add(colvarProductID);
                
                TableSchema.TableColumn colvarProductCode = new TableSchema.TableColumn(schema);
                colvarProductCode.ColumnName = "ProductCode";
                colvarProductCode.DataType = DbType.Int32;
                colvarProductCode.MaxLength = 0;
                colvarProductCode.AutoIncrement = false;
                colvarProductCode.IsNullable = false;
                colvarProductCode.IsPrimaryKey = false;
                colvarProductCode.IsForeignKey = false;
                colvarProductCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarProductCode);
                
                TableSchema.TableColumn colvarProductName = new TableSchema.TableColumn(schema);
                colvarProductName.ColumnName = "ProductName";
                colvarProductName.DataType = DbType.String;
                colvarProductName.MaxLength = 255;
                colvarProductName.AutoIncrement = false;
                colvarProductName.IsNullable = true;
                colvarProductName.IsPrimaryKey = false;
                colvarProductName.IsForeignKey = false;
                colvarProductName.IsReadOnly = false;
                
                schema.Columns.Add(colvarProductName);
                
                TableSchema.TableColumn colvarMediaType = new TableSchema.TableColumn(schema);
                colvarMediaType.ColumnName = "MediaType";
                colvarMediaType.DataType = DbType.String;
                colvarMediaType.MaxLength = 5;
                colvarMediaType.AutoIncrement = false;
                colvarMediaType.IsNullable = true;
                colvarMediaType.IsPrimaryKey = false;
                colvarMediaType.IsForeignKey = false;
                colvarMediaType.IsReadOnly = false;
                
                schema.Columns.Add(colvarMediaType);
                
                TableSchema.TableColumn colvarDateAdded = new TableSchema.TableColumn(schema);
                colvarDateAdded.ColumnName = "DateAdded";
                colvarDateAdded.DataType = DbType.DateTime;
                colvarDateAdded.MaxLength = 0;
                colvarDateAdded.AutoIncrement = false;
                colvarDateAdded.IsNullable = false;
                colvarDateAdded.IsPrimaryKey = false;
                colvarDateAdded.IsForeignKey = false;
                colvarDateAdded.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateAdded);
                
                TableSchema.TableColumn colvarDateModified = new TableSchema.TableColumn(schema);
                colvarDateModified.ColumnName = "DateModified";
                colvarDateModified.DataType = DbType.DateTime;
                colvarDateModified.MaxLength = 0;
                colvarDateModified.AutoIncrement = false;
                colvarDateModified.IsNullable = false;
                colvarDateModified.IsPrimaryKey = false;
                colvarDateModified.IsForeignKey = false;
                colvarDateModified.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateModified);
                
                TableSchema.TableColumn colvarDateAddedTv = new TableSchema.TableColumn(schema);
                colvarDateAddedTv.ColumnName = "DateAdded_TV";
                colvarDateAddedTv.DataType = DbType.DateTime;
                colvarDateAddedTv.MaxLength = 0;
                colvarDateAddedTv.AutoIncrement = false;
                colvarDateAddedTv.IsNullable = true;
                colvarDateAddedTv.IsPrimaryKey = false;
                colvarDateAddedTv.IsForeignKey = false;
                colvarDateAddedTv.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateAddedTv);
                
                TableSchema.TableColumn colvarDateAddedRd = new TableSchema.TableColumn(schema);
                colvarDateAddedRd.ColumnName = "DateAdded_RD";
                colvarDateAddedRd.DataType = DbType.DateTime;
                colvarDateAddedRd.MaxLength = 0;
                colvarDateAddedRd.AutoIncrement = false;
                colvarDateAddedRd.IsNullable = true;
                colvarDateAddedRd.IsPrimaryKey = false;
                colvarDateAddedRd.IsForeignKey = false;
                colvarDateAddedRd.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateAddedRd);
                
                TableSchema.TableColumn colvarDateAddedCb = new TableSchema.TableColumn(schema);
                colvarDateAddedCb.ColumnName = "DateAdded_CB";
                colvarDateAddedCb.DataType = DbType.DateTime;
                colvarDateAddedCb.MaxLength = 0;
                colvarDateAddedCb.AutoIncrement = false;
                colvarDateAddedCb.IsNullable = true;
                colvarDateAddedCb.IsPrimaryKey = false;
                colvarDateAddedCb.IsForeignKey = false;
                colvarDateAddedCb.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateAddedCb);
                
                TableSchema.TableColumn colvarDateAddedPr = new TableSchema.TableColumn(schema);
                colvarDateAddedPr.ColumnName = "DateAdded_PR";
                colvarDateAddedPr.DataType = DbType.DateTime;
                colvarDateAddedPr.MaxLength = 0;
                colvarDateAddedPr.AutoIncrement = false;
                colvarDateAddedPr.IsNullable = true;
                colvarDateAddedPr.IsPrimaryKey = false;
                colvarDateAddedPr.IsForeignKey = false;
                colvarDateAddedPr.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateAddedPr);
                
                TableSchema.TableColumn colvarDateAddedOd = new TableSchema.TableColumn(schema);
                colvarDateAddedOd.ColumnName = "DateAdded_OD";
                colvarDateAddedOd.DataType = DbType.DateTime;
                colvarDateAddedOd.MaxLength = 0;
                colvarDateAddedOd.AutoIncrement = false;
                colvarDateAddedOd.IsNullable = true;
                colvarDateAddedOd.IsPrimaryKey = false;
                colvarDateAddedOd.IsForeignKey = false;
                colvarDateAddedOd.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateAddedOd);
                
                TableSchema.TableColumn colvarDateAddedNs = new TableSchema.TableColumn(schema);
                colvarDateAddedNs.ColumnName = "DateAdded_NS";
                colvarDateAddedNs.DataType = DbType.DateTime;
                colvarDateAddedNs.MaxLength = 0;
                colvarDateAddedNs.AutoIncrement = false;
                colvarDateAddedNs.IsNullable = true;
                colvarDateAddedNs.IsPrimaryKey = false;
                colvarDateAddedNs.IsForeignKey = false;
                colvarDateAddedNs.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateAddedNs);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["Adex"].AddSchema("vProductNews",schema);
            }

        }

        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }

	    #endregion
	    
	    #region .ctors
	    public VProductNews()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }

        public VProductNews(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}

			MarkNew();
	    }

	    
	    public VProductNews(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }

    	 
	    public VProductNews(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }

        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("BrandID")]
        public int? BrandID 
	    {
		    get
		    {
			    return GetColumnValue<int?>("BrandID");
		    }

            set 
		    {
			    SetColumnValue("BrandID", value);
            }

        }

	      
        [XmlAttribute("BrandCode")]
        public int? BrandCode 
	    {
		    get
		    {
			    return GetColumnValue<int?>("BrandCode");
		    }

            set 
		    {
			    SetColumnValue("BrandCode", value);
            }

        }

	      
        [XmlAttribute("BrandName")]
        public string BrandName 
	    {
		    get
		    {
			    return GetColumnValue<string>("BrandName");
		    }

            set 
		    {
			    SetColumnValue("BrandName", value);
            }

        }

	      
        [XmlAttribute("ProductID")]
        public int ProductID 
	    {
		    get
		    {
			    return GetColumnValue<int>("ProductID");
		    }

            set 
		    {
			    SetColumnValue("ProductID", value);
            }

        }

	      
        [XmlAttribute("ProductCode")]
        public int ProductCode 
	    {
		    get
		    {
			    return GetColumnValue<int>("ProductCode");
		    }

            set 
		    {
			    SetColumnValue("ProductCode", value);
            }

        }

	      
        [XmlAttribute("ProductName")]
        public string ProductName 
	    {
		    get
		    {
			    return GetColumnValue<string>("ProductName");
		    }

            set 
		    {
			    SetColumnValue("ProductName", value);
            }

        }

	      
        [XmlAttribute("MediaType")]
        public string MediaType 
	    {
		    get
		    {
			    return GetColumnValue<string>("MediaType");
		    }

            set 
		    {
			    SetColumnValue("MediaType", value);
            }

        }

	      
        [XmlAttribute("DateAdded")]
        public DateTime DateAdded 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("DateAdded");
		    }

            set 
		    {
			    SetColumnValue("DateAdded", value);
            }

        }

	      
        [XmlAttribute("DateModified")]
        public DateTime DateModified 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("DateModified");
		    }

            set 
		    {
			    SetColumnValue("DateModified", value);
            }

        }

	      
        [XmlAttribute("DateAddedTv")]
        public DateTime? DateAddedTv 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("DateAdded_TV");
		    }

            set 
		    {
			    SetColumnValue("DateAdded_TV", value);
            }

        }

	      
        [XmlAttribute("DateAddedRd")]
        public DateTime? DateAddedRd 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("DateAdded_RD");
		    }

            set 
		    {
			    SetColumnValue("DateAdded_RD", value);
            }

        }

	      
        [XmlAttribute("DateAddedCb")]
        public DateTime? DateAddedCb 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("DateAdded_CB");
		    }

            set 
		    {
			    SetColumnValue("DateAdded_CB", value);
            }

        }

	      
        [XmlAttribute("DateAddedPr")]
        public DateTime? DateAddedPr 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("DateAdded_PR");
		    }

            set 
		    {
			    SetColumnValue("DateAdded_PR", value);
            }

        }

	      
        [XmlAttribute("DateAddedOd")]
        public DateTime? DateAddedOd 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("DateAdded_OD");
		    }

            set 
		    {
			    SetColumnValue("DateAdded_OD", value);
            }

        }

	      
        [XmlAttribute("DateAddedNs")]
        public DateTime? DateAddedNs 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("DateAdded_NS");
		    }

            set 
		    {
			    SetColumnValue("DateAdded_NS", value);
            }

        }

	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string BrandID = @"BrandID";
            
            public static string BrandCode = @"BrandCode";
            
            public static string BrandName = @"BrandName";
            
            public static string ProductID = @"ProductID";
            
            public static string ProductCode = @"ProductCode";
            
            public static string ProductName = @"ProductName";
            
            public static string MediaType = @"MediaType";
            
            public static string DateAdded = @"DateAdded";
            
            public static string DateModified = @"DateModified";
            
            public static string DateAddedTv = @"DateAdded_TV";
            
            public static string DateAddedRd = @"DateAdded_RD";
            
            public static string DateAddedCb = @"DateAdded_CB";
            
            public static string DateAddedPr = @"DateAdded_PR";
            
            public static string DateAddedOd = @"DateAdded_OD";
            
            public static string DateAddedNs = @"DateAdded_NS";
            
	    }

	    #endregion
    }

}

